package control;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.UpdateArticle;

@WebServlet("/EdioArticle")
public class EdioArticle extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setContentType("text/plain;charset=utf-8");
		
		String id = req.getParameter("id");
		String title = req.getParameter("title");
		String category = req.getParameter("category");
		String content = req.getParameter("content");
		
		UpdateArticle update = new UpdateArticle();
		
		boolean result = update.editContent(title, content, category, Integer.parseInt(id));
		
		PrintWriter out = resp.getWriter();
		out.print(result);
		out.close();
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO 自动生成的方法存根
	}
}
